import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Day0313 {
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        while (in.hasNextInt()) {// 注意，如果输入是多个测试用例，请通过while循环处理多个测试用例
            int a = in.nextInt();
            int b = in.nextInt();
            dp(a,b);
        }
    }
    public static void dp(int a,int b){
        int s=a*b;
        int m=Math.min(a,b);
        for (int i = m; i <=s ; i++) {
            if(i%a==0&&i%b==0){
                System.out.println(i);
                break;
            }
        }
    }


    public static void main(String[] args) throws IOException {
        BufferedReader reader=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(reader.readLine());
        String[] str=new String[n];
        for (int i = 0; i < n; i++) {
            str[i]=reader.readLine();
        }
        if(isLexicographically(str)&&isLength(str)){
            System.out.println("both");
        } else if (isLength(str)) {
            System.out.println("length");
        } else if (isLexicographically(str)) {
            System.out.println("lexicographically");
        }else {
            System.out.println("none");
        }
    }
    public static boolean isLexicographically(String[] str){
        for (int i = 0; i < str.length-1; i++) {
            if(str[i].compareTo(str[i+1])>0){
                return false;
            }
        }
        return true;
    }

    public static boolean isLength(String[] str){
        for (int i = 0; i < str.length-1; i++) {
            if(str[i].length()> str[i+1].length()){
                return false;
            }
        }
        return true;
    }
}
